import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;


@SuppressWarnings({ "serial", "rawtypes" })
/**
 * An extension of LinkedBlockingQueue that adds Set functionality.
 */
public class CrawlerQueue<E> extends LinkedBlockingQueue
{
	/**
	 * Set of Objects to check against.
	 */
	private Set<Object> my_set;
	
	/**
	 * Constructs a new CrawlerQueue object.
	 */
	public CrawlerQueue()
	{
		my_set = new HashSet<Object>();
	}
	
	@SuppressWarnings("unchecked")
	/**
	 * Cannot add duplicate objects.
	 * {@inheritDoc} 
	 */
	public synchronized boolean offer(Object e)
	{		
		return my_set.add(e) ? super.offer(e) : false;
	}
}
